﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SRM.DataObjects;
using System.Configuration;

public partial class RequisitionListing2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            tblContainer.Align = HorizontalAlign.Left.ToString();

            DataSet dsLocal = GetRequisition(string.Empty, string.Empty, string.Empty, "ALL", "ALL", DateTime.Parse("01/01/1900"), DateTime.MaxValue, "PO", "Y");
            DataSet dsOverseas = GetRequisition(string.Empty, string.Empty, string.Empty, "ALL", "ALL", DateTime.Parse("01/01/1900"), DateTime.MaxValue, "PO", "N");

            radLocal.DataSource = dsLocal;
            radLocal.DataBind();

            radOverseas.DataSource = dsOverseas;
            radOverseas.DataBind();

            radLocal.MasterTableView.SortExpressions.Clear();
            radLocal.MasterTableView.GroupByExpressions.Clear();
            radLocal.Width = Unit.Pixel(710);

            radOverseas.MasterTableView.SortExpressions.Clear();
            radOverseas.MasterTableView.GroupByExpressions.Clear();
            radOverseas.Width = Unit.Pixel(710);


            string strPos = SRM_Requisition.GetUnsolicitedRequisitionKey();

            tblDocForms.Visible = true;
            lblResume1.Visible = true;
            lblResume2.Visible = true;
            lblDepositResumeTitle.Text = "Deposit Resume";
            txtAppLink.Text = string.Format("<a target=\"_blank\" href=\"ApplicantForm.aspx?pos={0}\">Deposit your resume here</a>", strPos);

        }

    }

    protected void radLocal_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataSet dsLocal = GetRequisition(string.Empty, string.Empty, string.Empty, "ALL", "ALL", DateTime.Parse("01/01/1900"), DateTime.MaxValue, "PO", "Y");

        radLocal.DataSource = dsLocal;
    }

    protected void radOverseas_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataSet dsOverseas = GetRequisition(string.Empty, string.Empty, string.Empty, "ALL", "ALL", DateTime.Parse("01/01/1900"), DateTime.MaxValue, "PO", "N");

        radOverseas.DataSource = dsOverseas;
    }

    private DataSet GetRequisition(string strApplicant, string strApplicantStatus, string strRequisitionName, string strCompanyName, 
        string strLocationName, DateTime dtPostingDateFrom, DateTime dtPostingDateTo, string strStatusCode, string strLocalFlag)
    {
        return SRM_Requisition.SearchRequisition(strApplicant, strApplicantStatus, strRequisitionName, strCompanyName, 
            strLocationName, dtPostingDateFrom, dtPostingDateTo, strStatusCode, strLocalFlag);
    }
}